package cocoaas3.Titanium.UI{
	import jp.progression.casts.*;import jp.progression.commands.display.*;import jp.progression.commands.lists.*;import jp.progression.commands.managers.*;import jp.progression.commands.media.*;import jp.progression.commands.net.*;import jp.progression.commands.tweens.*;import jp.progression.commands.*;import jp.progression.data.*;import jp.progression.events.*;import jp.progression.loader.*;import jp.progression.*;import jp.progression.scenes.*;import jp.nium.core.debug.Logger;import jp.nium.utils.*;import caurina.transitions.*;import caurina.transitions.properties.*;
	import caurina.transitions.properties.*;
	import flash.events.*;
	import flash.display.*;
	import flash.net.*;

	import org.osflash.signals.*;


	import cocoaas3.Titanium.UI.*;

	public class WebWindow extends Window {

		[Embed(source="../../assets.swf", symbol='navBar.CloseButton_design')]
		private var CloseButton_design:Class;



		private var webview:WebView;
		private var toolbar:MyToolbar;


		public function WebWindow( url:String ){
			var close_btn = new CloseButton_design();
			close_btn.addEventListener( MouseEvent.CLICK, _close );

			webview = new WebView();
			webview.width = 640;
			webview.height = 960 - 88 - 88;
			webview.url = url;
			webview.locationChanging_sig.add( _onWebViewLocationChange );
			webview.complete_sig.add( _onWebViewLoadComplete );

			toolbar = new MyToolbar();
			toolbar.y = 960 - 88 - 88;
			toolbar.backButtonClick_sig.add( function(e){ webview.goBack() } );
			toolbar.forwardButtonClick_sig.add( function(e){ webview.goForward() } );

			this.rightNavButton = close_btn;
			this.add( webview );
			this.add( toolbar );
		}

		// ろーど開始
		private function _onWebViewLocationChange(){
			toolbar.spinner_mc.visible = true;
			toolbar.back_btn.alpha = 0.5;
			toolbar.back_btn.mouseEnabled = false;
			toolbar.forward_btn.alpha = 0.5;
			toolbar.forward_btn.mouseEnabled = false;
		}


		private function _onWebViewLoadComplete(){
			toolbar.spinner_mc.visible = false;
			if( webview.canGoBack() ){
				toolbar.back_btn.alpha = 1;
				toolbar.back_btn.mouseEnabled = true;
			}

			if( webview.canGoForward() ){
				toolbar.forward_btn.alpha = 1;
				toolbar.forward_btn.mouseEnabled = true;
			}
		}

		private function _close(e){
			this.close();
		}
	}
}


import jp.progression.casts.*;import jp.progression.commands.display.*;import jp.progression.commands.lists.*;import jp.progression.commands.managers.*;import jp.progression.commands.media.*;import jp.progression.commands.net.*;import jp.progression.commands.tweens.*;import jp.progression.commands.*;import jp.progression.data.*;import jp.progression.events.*;import jp.progression.loader.*;import jp.progression.*;import jp.progression.scenes.*;import jp.nium.core.debug.Logger;import jp.nium.utils.*;import caurina.transitions.*;import caurina.transitions.properties.*;
	
import flash.events.*;
import flash.display.*;
import flash.net.*;

import org.osflash.signals.*;
import org.osflash.signals.natives.*;

import cocoaas3.Titanium.UI.*;



class MyToolbar extends Toolbar{

	[Embed(source="../../assets.swf", symbol='toolbar.BackButton_design')]
	private var BackButton_design:Class;
	public var back_btn = new BackButton_design();

	[Embed(source="../../assets.swf", symbol='toolbar.ForwardButton_design')]
	private var ForwardButton_design:Class;
	public var forward_btn = new ForwardButton_design();

	[Embed(source="../../assets.swf", symbol='Spinner_design')]
	private var Spinner_design:Class;
	public var spinner_mc = new Spinner_design();


	public var backButtonClick_sig:NativeSignal;
	public var forwardButtonClick_sig:NativeSignal;

	public function MyToolbar(){
		ColorShortcuts.init();
		Tweener.addTween( spinner_mc, {"_color":0x000000, time:0} );

		back_btn.alpha = 0.5;
		forward_btn.alpha = 0.5;
		backButtonClick_sig = new NativeSignal( back_btn, MouseEvent.CLICK, MouseEvent );
		forwardButtonClick_sig = new NativeSignal( forward_btn, MouseEvent.CLICK, MouseEvent );

		var vec:Vector.<DisplayObject> = new Vector.<DisplayObject>();
		vec.push( back_btn );
		vec.push( forward_btn );

		super( vec );

		spinner_mc.x = 640 - 44;
		spinner_mc.y = 44;
		this.addChild( spinner_mc );
		//spinner_mc.visible = true;

	}
}



















